]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
popupMenu: Fix parenting implementation
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 15 Jul 2013 22:47:16 +0000 (18:47 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Wed, 17 Jul 2013 16:52:22 +0000 (12:52 -0400)
I got confused between menus and menu items.

https://bugzilla.gnome.org/show_bug.cgi?id=704336

js/ui/popupMenu.js

index 78f25db6867be0948d357e8c8c48f59053a1d622..824fe1dccc6a228dcaa8c5f0d46d42141e09b3f8 100644 (file)
@@ -56,6 +56,7 @@ const PopupBaseMenuItem = new Lang.Class({
         this.actor.connect('style-changed', Lang.bind(this, this._onStyleChanged));
         this.actor._delegate = this;
 
+        this._parent = null;
         this._children = [];
         this._ornament = Ornament.NONE;
         this._ornamentLabel = new St.Label({ style_class: 'popup-menu-ornament' });
@@ -84,6 +85,17 @@ const PopupBaseMenuItem = new Lang.Class({
         this.actor.connect('key-focus-out', Lang.bind(this, this._onKeyFocusOut));
     },
 
+    _getTopMenu: function() {
+        if (this._parent)
+            return this._parent._getTopMenu();
+        else
+            return this;
+    },
+
+    _setParent: function(parent) {
+        this._parent = parent;
+    },
+
     _onStyleChanged: function (actor) {
         this._spacing = Math.round(actor.get_theme_node().get_length('spacing'));
     },
@@ -671,6 +683,10 @@ const PopupMenuBase = new Lang.Class({
             return this;
     },
 
+    _setParent: function(parent) {
+        this._parent = parent;
+    },
+
     getSensitive: function() {
         return this._sensitive && this.parentSensitive;
     },
@@ -908,7 +924,7 @@ const PopupMenuBase = new Lang.Class({
         else
             throw TypeError("Invalid argument to PopupMenuBase.addMenuItem()");
 
-        menuItem._parent = this;
+        menuItem._setParent(this);
 
         this.length++;
     },
@@ -1342,6 +1358,11 @@ const PopupSubMenuMenuItem = new Lang.Class({
         this.menu.connect('open-state-changed', Lang.bind(this, this._subMenuOpenStateChanged));
     },
 
+    _setParent: function(parent) {
+        this.parent(parent);
+        this.menu._setParent(parent);
+    },
+
     syncSensitive: function() {
         let sensitive = this.parent();
         this._triangle.visible = sensitive;